<template>
  <!-- 预览数量和收藏数量 -->
  <div class="subject-box">
    <span class="subject-box">{{ view_count }}浏览</span>
    <div class="subject-count" @click.stop="addLike">
      <span class="icon">
        <img src="@/assets/goImages/1t.png" alt="" v-if="likeState" />
        <img src="@/assets/star/Up.png" alt="" v-else />
      </span>
      <span class="count">{{ like }}</span>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    view_count: [Number, String],
    like_count: [Number, String]
  },
  data() {
    return {
      likeState: false,
      like: this.like_count
    }
  },
  methods: {
    addLike() {
      this.likeState = !this.likeState
      if (this.likeState) {
        this.like++
      } else {
        this.like--
      }
    }
  }
}
</script>

<style lang="less" scoped>
.subject-box {
  display: flex;
  padding: 5px 0;
  margin-bottom: 10px;
  justify-content: space-between;
  align-items: center;

  .subject-box {
    color: #b6b6b6;
    font-size: 14px;
  }

  .subject-count {
    display: flex;
    align-items: center;

    .icon {
      height: 14px;
      width: 14px;
      margin-right: 10px;

      img {
        height: 100%;
        width: 100%;
      }
    }
    .count {
      color: #b6b6b6;
      font-size: 14px;
    }
  }
}
</style>
